#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long LL;

int n,m;
LL arr[N];
LL ans;
struct Node{
    int l,r;
    LL minum;
    Node* left;
    Node* right;
    Node(int l_,int r_){
        l=l_;r=r_;
        left=right=nullptr;
    }
};

Node* build(int l,int r){
    Node* root=new Node{l,r};
    if(l==r){
        root->minum=arr[l];
        return root;
    }
    int mid=(r-l)/2+l;
    root->left=build(l,mid);
    root->right=build(mid+1,r);
    root->minum=min(root->left->minum,root->right->minum);
    return root;
}
void search(const int l,const int r,Node* root){
	if(!root||l>root->r||r<root->l) return;
    if(l<=root->l&&r>=root->r){
        ans=min(ans,root->minum);
        return;
    }
    int mid=(root->r-root->l)/2+root->l;
    if(l<=mid) search(l,r,root->left);
    if(r>mid) search(l,r,root->right);
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld",&arr[i]);
    }
    //build
    Node* root=build(1,n);
    //search
    int l,r;
    for(int j=1;j<=m;j++){
        scanf("%d%d",&l,&r);
        ans=LLONG_MAX;
        search(l,r,root);
        printf("%lld ",ans);
    }
    return 0;
}
/*
10 10
1 2 3 4 5 6 7 8 9 10
2 7
3 9
1 10
*/
